import 'package:flutterdemo/models/entity/face_entity.dart';

faceEntityFromJson(FaceEntity data, Map<String, dynamic> json) {
	if (json['IsSuccess'] != null) {
		data.isSuccess = json['IsSuccess'];
	}
	if (json['Msg'] != null) {
		data.msg = json['Msg'].toString();
	}
	if (json['errmsg'] != null) {
		data.errmsg = json['errmsg'].toString();
	}
	if (json['errcode'] != null) {
		data.errcode = json['errcode'] is String
				? int.tryParse(json['errcode'])
				: json['errcode'].toInt();
	}
	if (json['Data'] != null) {
		data.data = new FaceData().fromJson(json['Data']);
	}
	if (json['Status'] != null) {
		data.status = json['Status'] is String
				? int.tryParse(json['Status'])
				: json['Status'].toInt();
	}
	if (json['ExecuteMilliseconds'] != null) {
		data.executeMilliseconds = json['ExecuteMilliseconds'].toString();
	}
	return data;
}

Map<String, dynamic> faceEntityToJson(FaceEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['IsSuccess'] = entity.isSuccess;
	data['Msg'] = entity.msg;
	data['errmsg'] = entity.errmsg;
	data['errcode'] = entity.errcode;
	if (entity.data != null) {
		data['Data'] = entity.data.toJson();
	}
	data['Status'] = entity.status;
	data['ExecuteMilliseconds'] = entity.executeMilliseconds;
	return data;
}

faceDataFromJson(FaceData data, Map<String, dynamic> json) {
	if (json['RecordCount'] != null) {
		data.recordCount = json['RecordCount'] is String
				? int.tryParse(json['RecordCount'])
				: json['RecordCount'].toInt();
	}
	if (json['PageCount'] != null) {
		data.pageCount = json['PageCount'] is String
				? int.tryParse(json['PageCount'])
				: json['PageCount'].toInt();
	}
	if (json['Records'] != null) {
		data.records = new List<FaceDataRecord>();
		(json['Records'] as List).forEach((v) {
			data.records.add(new FaceDataRecord().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> faceDataToJson(FaceData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['RecordCount'] = entity.recordCount;
	data['PageCount'] = entity.pageCount;
	if (entity.records != null) {
		data['Records'] =  entity.records.map((v) => v.toJson()).toList();
	}
	return data;
}

faceDataRecordFromJson(FaceDataRecord data, Map<String, dynamic> json) {
	if (json['Id'] != null) {
		data.id = json['Id'] is String
				? int.tryParse(json['Id'])
				: json['Id'].toInt();
	}
	if (json['StaffName'] != null) {
		data.staffName = json['StaffName'].toString();
	}
	if (json['OpenDate'] != null) {
		data.openDate = json['OpenDate'].toString();
	}
	if (json['AreaName'] != null) {
		data.areaName = json['AreaName'].toString();
	}
	if (json['OrgName'] != null) {
		data.orgName = json['OrgName'].toString();
	}
	if (json['CommunityName'] != null) {
		data.communityName = json['CommunityName'].toString();
	}
	if (json['AccessName'] != null) {
		data.accessName = json['AccessName'].toString();
	}
	if (json['ChannelName'] != null) {
		data.channelName = json['ChannelName'].toString();
	}
	if (json['AccessType'] != null) {
		data.accessType = json['AccessType'].toString();
	}
	if (json['OpenPicture'] != null) {
		data.openPicture = json['OpenPicture'].toString();
	}
	if (json['FacePicture'] != null) {
		data.facePicture = json['FacePicture'].toString();
	}
	if (json['IdentityType'] != null) {
		data.identityType = json['IdentityType'].toString();
	}
	if (json['PasswayType'] != null) {
		data.passwayType = json['PasswayType'].toString();
	}
	return data;
}

Map<String, dynamic> faceDataRecordToJson(FaceDataRecord entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['Id'] = entity.id;
	data['StaffName'] = entity.staffName;
	data['OpenDate'] = entity.openDate;
	data['AreaName'] = entity.areaName;
	data['OrgName'] = entity.orgName;
	data['CommunityName'] = entity.communityName;
	data['AccessName'] = entity.accessName;
	data['ChannelName'] = entity.channelName;
	data['AccessType'] = entity.accessType;
	data['OpenPicture'] = entity.openPicture;
	data['FacePicture'] = entity.facePicture;
	data['IdentityType'] = entity.identityType;
	data['PasswayType'] = entity.passwayType;
	return data;
}